#include "UnitTest++.h"
#include "stb_image.hpp"
#include <iostream>
using namespace std;


TEST (Png_read)
{
    unsigned char* pixels;
    int            width;
    int            height;
    int            bpp;

    pixels = stbi_load ("../res/test01.png", &width, &height, &bpp, 0);

    CHECK (pixels != NULL);

    CHECK_EQUAL (64, width );
    CHECK_EQUAL (64, height);
    CHECK_EQUAL (3 , bpp   );


	CHECK_CLOSE (255, (int)pixels[0+0], 1.f);
	CHECK_CLOSE (0  , (int)pixels[0+1], 1.f);
	CHECK_CLOSE (0  , (int)pixels[0+2], 1.f);

	CHECK_CLOSE (0  , (int)pixels[63*3+0], 1.f);
	CHECK_CLOSE (0  , (int)pixels[63*3+1], 1.f);
	CHECK_CLOSE (255, (int)pixels[63*3+2], 1.f);

	CHECK_CLOSE (0  , (int)pixels[63*64*3+0], 1.f);
	CHECK_CLOSE (255, (int)pixels[63*64*3+1], 1.f);
	CHECK_CLOSE (0  , (int)pixels[63*64*3+2], 1.f);
	
	CHECK_CLOSE (255, (int)pixels[63*64*3+63*3+0], 1.f);
	CHECK_CLOSE (255, (int)pixels[63*64*3+63*3+1], 1.f);
	CHECK_CLOSE (255, (int)pixels[63*64*3+63*3+2], 1.f);
	

    stbi_image_free (pixels);
}